SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[imovelTipoInsert]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'

CREATE PROCEDURE spImovelTipoInsert
(
	@NomeTipo Varchar(100)	
)
AS

INSERT imovelTipo 
(
	
	imt_nome
) 
	VALUES 
(
	
	@NomeTipo
)
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[imovelTipoSelect]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spImovelTipoSelect
(
	@Id Int
)
AS
SELECT
	imt_id,	
	imt_nome	
FROM
	imovelTipo
WHERE 
	imt_id = @Id
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[imovelTipoUpdate]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spImovelTipoUpdate
(
	@Id Int,
	@NomeTipo Varchar(100)	
)
AS
UPDATE imovelTipo SET
	imt_nome = @NomeTipo
	
WHERE imt_id = @Id
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[imovelTipoSelectAll]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spImovelTipoSelectAll
	
AS   SELECT imt_id, imt_nome FROM  dbo.imovelTipo
ORDER BY imt_nome
	SET NOCOUNT ON 
	RETURN
' 
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[imovelTipoDelete]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE PROCEDURE spImovelTipoDelete
(
	@Id Int
)
AS
DELETE 
	imovelTipo 
WHERE 
	imt_id=@Id
' 
END
